from flask import Blueprint,jsonify,request,json
from db import db1
# from utils.comm import get_data
bp_auser=Blueprint("adminuser",__name__)
@bp_auser.route('/roleM',methods=['POST','GET'])
def roleM():
    if request.method=='POST':
        data = request.data
        if data:
            data = json.loads(data)
        else:
            data = request.form
        sql="select id from roles wh ere name='%s'"%(data['name'])
        res=db1.find(sql)
        if res:
            return jsonify({'code':20010})
        else:
            sql1="insert into roles values(0,'%s')"%(data['name'])
            db1.update(sql1)
            return jsonify({'code':200})
    else:
        pass